#ifndef AVDEMUXER_H
#define AVDEMUXER_H
#include<QString>
#include<functional>
#include<atomic>
#include<thread>
#include<memory>//智能指针
#include<functional>
struct AVFormatContext;
class AVDeMuxer
{
public:
    AVDeMuxer();
    bool Open(const QString path);
    using StreamCallback=std::function<void(bool)>;
    inline void SetStreamCallback(const StreamCallback& cb){streamCb_=cb;};
protected:
    void Close();
    void FetchStream(const QString path);
    bool FetchSteamInfo(const QString path);
    static int InterruptFountion(void*arg);//通过这个函数返回值停止拉流
private:
    int videoIndex=-1;
    int AudioIndex=-1;
     std::atomic_bool quit_;
    AVFormatContext*pFormatCtx_=nullptr;
    std::unique_ptr<std::thread> readThread_=nullptr;
    StreamCallback streamCb_=[](bool){};
};

#endif // AVDEMUXER_H
